//
//  FillInTheOrderViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/27.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "FillInTheOrderViewController.h"
#import "FillInTheOrderViewModel.h"
#import "DistributionTypeViewController.h"
#import "ChangePayTypeViewController.h"
#import "MyAdressModel.h"
#import "MyAdressViewController.h"

@interface FillInTheOrderViewController ()<FillnOrderDelegate>
@property (nonatomic,strong) FillInTheOrderViewModel * fillViewModel;
@property (nonatomic, strong) MyAdressModel_Infos *addressModel;

@end

@implementation FillInTheOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"填写订单";
    self.fillViewModel = [[FillInTheOrderViewModel alloc] initWithViewToViewModel:self.tableView theSuperView:self.view];
    self.fillViewModel.orderID = self.orderID;
    self.fillViewModel.delegate = self;
}

#pragma mark -- FillnOrderDelegate
- (void)fillnSelectIndex:(NSIndexPath *)fill_index {
    switch (fill_index.section) {
        case 0:{
            if (fill_index.row == 0) {
                DistributionTypeViewController * distributionVC = [DistributionTypeViewController new];
                kWeakSelf(self);
                distributionVC.BlockSelectRow = ^(FillExpressModel * _Nonnull model) {
                    [weakself didSelectRow:model];
                };
                [self.navigationController pushViewController:distributionVC animated:YES];
            } else if (fill_index.row == 1) {
                kWeakSelf(self);
                MyAdressViewController *vc = [MyAdressViewController new];
                vc.BlockChooseAdrees = ^(MyAdressModel_Infos * _Nonnull model) {
                    [weakself chooseAdress:model];
                };
                [self.navigationController pushViewController:vc animated:YES];
            } else {
                ChangePayTypeViewController * payTypeVC = [ChangePayTypeViewController new];
                [self.navigationController pushViewController:payTypeVC animated:YES];
            }
        }
            break;
            
        default:
            break;
    }
}

- (void)chooseAdress:(MyAdressModel_Infos *)model
{
    self.fillViewModel.addressModel = model;
}

- (void)didSelectRow:(FillExpressModel *)model
{
    self.fillViewModel.lastPageModel = model;
}

@end
